package com.cosina.game.robodefence.eventlistener;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.cosina.game.robodefence.R;
import com.cosina.game.robodefence.dao.AchievementDao;
import com.cosina.game.robodefence.model.Achievement;

public class AchievementArrayAdapter extends ArrayAdapter<Achievement>{

	public AchievementArrayAdapter(Context context) {
		super(context, R.layout.achievementitem, AchievementDao.getRewards());
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(null == convertView){
			String inflater = Context.LAYOUT_INFLATER_SERVICE;
			LayoutInflater vi = (LayoutInflater)getContext().getSystemService(inflater);
			convertView = vi.inflate(R.layout.achievementitem, null);
			Log.e("cosina1985", "" + convertView.getClass().getName());
		}
		
		TextView title = (TextView)convertView.findViewById(R.id.achiTitle);
		TextView desc = (TextView)convertView.findViewById(R.id.achiDesc);
		Achievement achievement = this.getItem(position);
		title.setText(achievement.title);
		desc.setText(achievement.description);
		return convertView;
	}
}
